//服务端 koa
const Koa = require("koa");
const Server = require("koa-static");
const path = require("path");

const app = new Koa();

app.use(async (ctx, next) => {
  if (ctx.path === "/api/list") {
    ctx.body = { name: "小白", age: 18, sex: "男" };
  }else{
    return next();
  }
});

app.use(Server(path.join(__dirname, "client")));
app.use(Server(path.join(__dirname, "node_modules")));

app.listen(3000, function () {
  console.log("server is running at http://localhost:3000");
});
